package com.yt.cli.example;

import picocli.CommandLine;

@CommandLine.Command(name = "main", mixinStandardHelpOptions = true)
public class SubCommandExample implements Runnable{



    @Override
    public void run() {
        System.out.println("执行主命令");
    }

    @CommandLine.Command(name = "-add", description = "添加", mixinStandardHelpOptions = true)
    static class AddCommend implements Runnable {

        @Override
        public void run() {
            System.out.println("执行添加命令");
        }
    }

    @CommandLine.Command(name = "-delete", description = "删除", mixinStandardHelpOptions = true)
    static class DeleteCommend implements Runnable {

        @Override
        public void run() {
            System.out.println("执行删除命令");
        }
    }

    @CommandLine.Command(name = "-query", description = "查询", mixinStandardHelpOptions = true)
    static class QueryCommend implements Runnable {

        @Override
        public void run() {
            System.out.println("执行查询命令");
        }
    }

    public static void main(String[] args) {
        String[] myArgs = new String[]{"-add", "--help"};
        int exit = new CommandLine(new SubCommandExample())
                .addSubcommand(new AddCommend())
                .addSubcommand(new DeleteCommend())
                .addSubcommand(new QueryCommend())
                .execute(myArgs);

        System.exit(exit);
    }
}
